package com.wfu.module_local_video.dao;

import android.annotation.SuppressLint;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.provider.MediaStore;
import android.support.annotation.NonNull;

import java.util.Objects;
import java.util.concurrent.TimeUnit;

import io.reactivex.Flowable;
import io.reactivex.schedulers.Schedulers;

/**
 * Describe:
 * Author: wfy
 * Version:
 * Create by (wfy) on 2018/5/10 3:19
 * <p>
 * company :
 */
public class LVideoDao {
    @SuppressLint("CheckResult")
    public Flowable<Cursor> getData(@NonNull Context context) {
        Uri uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
        String[] objs = {
                MediaStore.Video.Media.DISPLAY_NAME,//视频文件在sdcard的名称
                MediaStore.Video.Media.DURATION,//视频总时长
                MediaStore.Video.Media.SIZE,//视频的文件大小
                MediaStore.Video.Media.DATA,//视频的绝对地址
                MediaStore.Video.Media.ARTIST,//歌曲的演唱者
        };
        return Flowable.just(Objects.requireNonNull(context.getContentResolver().query(uri, objs, null, null, null)))
                .subscribeOn(Schedulers.newThread())
                .observeOn(Schedulers.newThread())
                .delay(2000, TimeUnit.MILLISECONDS);
    }
}
